package com.lsj.webSpring.core.convert;


import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Lsj
 * @version 1.0
 * @date 2021/6/28 20:58
 */
public class StringToDateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String source) {
        // 判断
        if (StrUtil.isBlank(source)){
            return null;
        }
        return DateUtil.parse(source,"yyyy-MM-dd");
    }
}
